﻿Imports WindowsLive.Writer.Api
Imports System.Runtime.CompilerServices

Module PropertiesExtension

#Region "SyntaxHighlighter options"

    <Extension()> _
    Public Function GetLanguage(ByVal p As IProperties) As String
        Return p.GetString("Lang", "c")
    End Function

    <Extension()> _
    Public Sub SetLanguage(ByVal p As IProperties, ByVal language As String)
        p.SetString("Lang", language)
    End Sub


    <Extension()> _
    Public Function GetNoGutter(ByVal p As IProperties) As Boolean
        Return p.GetBoolean("NoGutter", False)
    End Function

    <Extension()> _
    Public Sub SetNoGutter(ByVal p As IProperties, ByVal noGutter As Boolean)
        p.SetBoolean("NoGutter", noGutter)
    End Sub


    <Extension()> _
    Public Function GetNoControls(ByVal p As IProperties) As Boolean
        Return p.GetBoolean("NoControls", False)
    End Function

    <Extension()> _
    Public Sub SetNoControls(ByVal p As IProperties, ByVal noControls As Boolean)
        p.SetBoolean("NoControls", noControls)
    End Sub


    <Extension()> _
    Public Function GetCollapse(ByVal p As IProperties) As Boolean
        Return p.GetBoolean("Collapse", False)
    End Function

    <Extension()> _
    Public Sub SetCollapse(ByVal p As IProperties, ByVal collapse As Boolean)
        p.SetBoolean("Collapse", collapse)
    End Sub


    <Extension()> _
    Public Function GetFirstLine(ByVal p As IProperties) As Boolean
        Return p.GetBoolean("FirstLine", False)
    End Function

    <Extension()> _
    Public Sub SetFirstLine(ByVal p As IProperties, ByVal firstLine As Boolean)
        p.SetBoolean("FirstLine", firstLine)
    End Sub


    <Extension()> _
    Public Function GetShowColumns(ByVal p As IProperties) As Boolean
        Return p.GetBoolean("ShowColumns", False)
    End Function

    <Extension()> _
    Public Sub SetShowColumns(ByVal p As IProperties, ByVal showColumns As Boolean)
        p.SetBoolean("ShowColumns", showColumns)
    End Sub


    <Extension()> _
    Public Function GetLineValue(ByVal p As IProperties) As Decimal
        Return p.GetDecimal("LineValue", 1)
    End Function

    <Extension()> _
    Public Sub SetLineValue(ByVal p As IProperties, ByVal lineValue As Decimal)
        p.SetDecimal("LineValue", lineValue)
    End Sub

#End Region

#Region "Editor Action"

    <Extension()> _
    Public Function GetInsertedAction(ByVal p As IProperties) As EditorActions
        Return CType(p.GetInt("InsertedAction", EditorActions.DoNothing), EditorActions)
    End Function

    <Extension()> _
    Public Sub SetInsertedAction(ByVal p As IProperties, ByVal action As EditorActions)
        p.SetInt("InsertedAction", action)
    End Sub


    <Extension()> _
    Public Function GetEditedAction(ByVal p As IProperties) As EditorActions
        Return CType(p.GetInt("EditedAction", EditorActions.DoNothing), EditorActions)
    End Function

    <Extension()> _
    Public Sub SetEditedAction(ByVal p As IProperties, ByVal action As EditorActions)
        p.SetInt("EditedAction", action)
    End Sub


    <Extension()> _
    Public Function GetTabSize(ByVal p As IProperties) As Integer
        Return p.GetInt("TabSize", 4)
    End Function

    <Extension()> _
    Public Sub SetTabSize(ByVal p As IProperties, ByVal size As Integer)
        p.SetInt("TabSize", size)
    End Sub

#End Region

    <Extension()> _
    Public Function GetCode(ByVal p As IProperties) As String
        Return p.GetString("Code", "")
    End Function

    <Extension()> _
    Public Sub SetCode(ByVal p As IProperties, ByVal code As String)
        p.SetString("Code", code)
    End Sub

End Module
